package mya.mes.mdc.mqtt;

public class TimeIdGenerator {

    private volatile long timeOld = System.currentTimeMillis();

    private static TimeIdGenerator _instance = new TimeIdGenerator();


    public static TimeIdGenerator getInstance() {
        return _instance;
    }


    public synchronized long getId(long timestamp) {
        if (timestamp > timeOld) {
            timeOld = timestamp;
            return timeOld;
        }

        timeOld++;

        return timeOld;
    }
}
